﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
#endregion

namespace NetBay.Core.BusinessEntities
{
    /// <summary>
    /// DATABASE TABLENAME : r_ALERTES
    /// </summary>
    [DataContract]
    public class Alert : ReturnObject
    {
        /// <summary>
        /// Alert database Identifier
        /// </summary>
        private long m_lIdentifier;
        
        [DataMember]
        public long Identifier
        {
            get { return m_lIdentifier; }
            set { m_lIdentifier = value; }
        }
        
        /// <summary>
        /// Name of the alert
        /// </summary>
        private string m_sName;
        
        [DataMember]
        public string Name
        {
            get { return m_sName; }
            set { m_sName = value; }
        }
        
        /// <summary>
        /// Object of the alert
        /// </summary>
        private string m_sObject;

        [DataMember]
        public string Object
        {
            get { return m_sObject; }
            set { m_sObject = value; }
        }

        /// <summary>
        /// Body of the alert
        /// </summary>
        private string m_sBody;

        [DataMember]
        public string Body
        {
            get { return m_sBody; }
            set { m_sBody = value; }
        }

        /// <summary>
        /// Date of the alert
        /// </summary>
        private DateTime m_dDate;

        [DataMember]
        public DateTime Date
        {
            get { return m_dDate; }
            set { m_dDate = value; }
        }

        /// <summary>
        /// Identifier of the alert Status 
        /// </summary>
        private long m_lStatusIdentifier;

        [DataMember]
        public long StatusIdentifier
        {
            get { return m_lStatusIdentifier; }
            set { m_lStatusIdentifier = value; }
        }

        /// <summary>
        /// Name of the alert status
        /// </summary>
        private string m_sStatusName;

        [DataMember]
        public string StatusName
        {
            get { return m_sStatusName; }
            set { m_sStatusName = value; }
        }

        [DataMember]
        public int? ActionId { get; set; }

        [DataMember]
        public string ActionLabel { get; set; }

        /// <summary>
        /// The database identifier of the user that creates the alert
        /// </summary>
        private long m_lUserCreationIdentifier;

        [DataMember]
        public long UserCreationIdentifier
        {
            get { return m_lUserCreationIdentifier; }
            set { m_lUserCreationIdentifier = value; }
        }

        /// <summary>
        /// the creation date of the alert
        /// </summary>
        private DateTime m_sCreationDate;

        [DataMember]
        public DateTime CreationDate
        {
            get { return m_sCreationDate; }
            set { m_sCreationDate = value; }
        }

        /// <summary>
        /// the date the alert has been sent
        /// </summary>
        private DateTime m_sSendDate;

        [DataMember]
        public DateTime SendDate
        {
            get { return m_sSendDate; }
            set { m_sSendDate = value; }
        }

        /// <summary>
        /// The list of the groups impacted by the alert.
        /// </summary>
        private List<Group> m_lstGroup;
        
        [DataMember]
        public List<Group> GroupList
        {
            get { return m_lstGroup; }
            set { m_lstGroup = value; }
        }

        /// <summary>
        /// The Email of the user that create the alert
        /// </summary>
        private string m_sUserEmail;
        [DataMember]
        public string UserEmail
        {
            get { return m_sUserEmail; }
            set { m_sUserEmail = value; }
        }



        /// <summary>
        /// Get the group name list with a semi column separator
        /// </summary>
        [DataMember]
        public string GroupListName
        {
            get
            {
                string l_sReturn = string.Empty;
                foreach (Group l_oOneGroup in m_lstGroup)
                {
                    l_sReturn += l_oOneGroup.Name + ";";
                }
                return l_sReturn;
            }
            set { }
        }

        #region Init/Constructor
        
        /// <summary>
        /// Default constructor 
        /// </summary>
        public Alert() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public Alert(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException) { }

        #endregion
    }

    public abstract class AlertDer : Alert { }
}
